package cn.tedu.knows.portal.mapper;

import cn.tedu.knows.portal.model.Question;
import cn.tedu.knows.portal.model.QuestionTag;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author tedu.cn
 * @since 2021-10-27
 */
@Repository
public interface QuestionMapper extends BaseMapper<Question> {
    //根据用户id查询收藏数
    @Select("select count(*) from question where user_id=#{id}")
    int countQuestionsByUserId(Integer userId);
    //查询讲师问题列表的方法
    @Select("SELECT  q.* FROM question q  LEFT  join user_question uq ON q.id=uq.question_id WHERE uq.user_id=3 OR\n" +
            "q.user_id=3 ORDER BY q.createtime desc")
    List<Question> findTeacherQuestions(Integer userId);

}
